﻿@{
    ViewBag.Title = "AddMaterial";
    Layout = "~/Views/Shared/_FlowForm.cshtml";
}
<script>

    var keyValue = request('keyValue');
    var type = request('type');
    $(document).ready(function () {     
        if( (!!keyValue))
        {  
            $.ajax({
                type: "POST",
                url: "../../PropertyManage/CS_MaterialSetting/GetFormJson",               
                data: { keyValue: keyValue },
                success: function (data) {                    
                    $("#BaseInfo").SetWebControls(JSON.parse(data));
                }
            })
        };

        //图片上传插件
        $('#file_upload').uploadify({
            //是否自动上传
            'auto': false,
            //超时时间
            'successTimeout': 99999,
            //上传文件的大小限制
            'fileSizeLimit': '2GB',
            'queueSizeLimit': 5,
            'uploader': 'Upload',
            //传递参数给上面uploader处理程序
            'formData': {
                'username': 'Amos',
                'userpwd': '123456'
            },
            'swf': '@Url.Content("~/Content/scripts/plugins/uploadify/uploadify.swf")',
            'buttonText': '点击选择图片',
            //上传文件选择按钮的高度
            'height': 30,
            //上传文件选择按钮的宽度
            'width': 120,
            //文件选择后的容器ID
            'queueID': 'queue',
            //在浏览窗口底部的文件类型下拉菜单中显示的文本
            'fileTypeDesc': '支持的格式：',
            //允许上传的文件后缀
            'fileTypeExts': '*.jpg;*.jpge;*.gif;*.png;',
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {
                    case -100:
                        alert("上传的文件数量已经超出系统限制的" + jQuery('#file_upload').uploadify('settings', 'queueSizeLimit') + "个文件！");
                        break;
                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + jQuery('#file_upload').uploadify('settings', 'fileSizeLimit') + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            },
            'onClearQueue': function (queueItemCount) {
                alert("取消上传");
                return;
            },
            'onQueueComplete': function (queueData) {
                
                //alert("文件上传成功！");
                return;
            },
            'onUploadSuccess': function (file, data, response)
            {
                alert("文件上传成功！");              
                data = JSON.parse(data);               
                $("#yr").html("<img src='/Uploads/"+data.SaveName+"' style='width:100px;height:100px;' />");
                $("#DemoImage").val(data.SaveName);
                
            }
        });
    })

    
       

    //保存
    function AcceptClick(obj) {       
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = $("#form1").GetWebControls("");
        postData["Type"]=type;
        $.ajax({
            type: "GET",
            url: "../../PropertyManage/CS_MaterialSetting/SaveMaterial?keyValue=" + keyValue,
            async: false,
            data: postData,
            success: function (data) {
               

            }
        })      
        dialogMsg("操作成功。", 1);
        dialogClose();
       
    }
</script>
    <div id="BaseInfo" class="tab-pane active" style=" padding-right: 30px;">
        <table class="form">
            <tr>
                <td class="formTitle">资料名称<font face="宋体">*</font></td>
                <td class="formValue">
                    <input id="Name" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />
                </td>
               
            </tr>
            <tr>
                <td class="formTitle">排序<font face="宋体">*</font></td>
                <td class="formValue">
                    <input id="Sort" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" />
                    
                </td>
               
            </tr>
            <tr>
                <td class="formTitle">选项</td>
                <td class="formValue">
                    <input type="checkbox" name="IsSubmit" id="IsSubmit" value="1">提交
                    <input type="checkbox" name="IsUpload" id="IsUpload" value="1">上传
                    <input type="checkbox" name="EnabledMark" id="EnabledMark" value="1">有效
                    <input type="checkbox" name="DeleteMark" id="DeleteMark" value="1">可删除
                </td>
               

            </tr>
        
            <tr>
                <th class="formTitle" valign="top" style="padding-top: 4px;">
                    资料说明
                </th>
                <td class="formValue" >
                    <textarea id="Description" class="form-control" style="height: 50px;"></textarea>
                </td>
            </tr>
            <tr>
                <th class="formTitle" valign="top" style="padding-top: 4px;">
                    示例图片
                </th>
                <td class="formValue">
                    <input type="file" id="file_upload" name="file_upload" />
                    <a style=" text-decoration:none;" href="javascript:jQuery('#file_upload').uploadify('upload','*')" id="a_upload" class="btn btn-default"
                       name="a_upload">&nbsp;&nbsp;上传&nbsp;&nbsp;</a>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="hidden" id="DemoImage" />
                </td>
                <td  >
                    <div id="yr" style="height:100px;"></div>
                </td>
            </tr>
            <tr>
                <th class="formTitle" valign="top" style="padding-top: 4px;">
                    备注
                </th>
                <td class="formValue">
                    <textarea id="Memo" class="form-control" style="height: 50px;"></textarea>
                </td>
            </tr>
        </table>
    </div>
